﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace GestorSQL.Utility
{
    public enum LoggType
    {
        Info,
        Debug,
        Error,
        Warn,
        Fatal

    }

    public static class Logger
    {
        private static ILog logger = log4net.LogManager.GetLogger(typeof(Logger));

        private static bool _isConfigured = false;

        private static void _Configure()
        {
            if (!_isConfigured)
            {
                log4net.Config.XmlConfigurator.Configure();
                _isConfigured = true;
            }
        }


        public static void Logg(this Exception ex, LoggType type)
        {
            _Configure();
            switch (type)
            {
                case LoggType.Info:
                    logger.Info(ex.ToString());
                    break;
                case LoggType.Debug:
                    logger.Debug(ex.ToString());
                    break;
                case LoggType.Error:
                    logger.Error(ex.ToString());
                    break;
                case LoggType.Warn:
                    logger.Warn(ex.ToString());
                    break;
                case LoggType.Fatal:
                    logger.Fatal(ex.ToString());
                    break;
            }
        }

    }
}
